<div class="content_pink text-center">
    <div class="cover">
        <div class="cover_images">
            <img src="<?php echo $domain; ?>/images/cover_image.png"/>
        </div>
        <div class="cover_flower">
            <img src="<?php echo $domain; ?>/images/cover_flower.png"/>
        </div>
    </div><!--cover-->
    <div class="box_contact">
        <div class="content_contact">
            <div class="icon_flower1">
                <img src="<?php echo $domain; ?>/images/icon_flower1.png"/>
            </div>
            <div class="icon_flower2">
                <img src="<?php echo $domain; ?>/images/icon_flower2.png"/>
            </div>
            <div class="contact">
                <h1>Liên hệ</h1>
                <span>+84(4)6273-1346</span>
                <span>080-4135-6092</span>
            </div>
        </div>
    </div><!--lien he-->
    <div class="content-pr-detail">
        
            <div class="info-pr-detail">
            <div class="img-info-detail">
                <img style="width: 289px; height: 337px;" src="<?php echo $domain.'/'.$product['Product']['images'] ?>"/>
            </div>
            <div class="content-info-detail">
                <h1><?php echo $product['Product']['name'] ?></h1>
                <p class="danhgia-sanpham">
				<br />
                </p>
                <p class="icon-tron"><img src="<?php echo $domain; ?>/images/icon-tron.png"/> Mã sản phẩm: <?php echo $product['Product']['code'] ?></p>
                <p class="icon-tron"><img src="<?php echo $domain; ?>/images/icon-tron.png"/> Khối lượng: <?php echo $product['Product']['sl'] ?>g</p>
                <p class="icon-tron"><img src="<?php echo $domain; ?>/images/icon-tron.png"/>Xuất xứ: <?php echo $product['Product']['name_en'] ?> </p>
				<p class="icon-tron"><img src="<?php echo $domain; ?>/images/icon-tron.png"/>Quy cách đóng gói: <?php echo $product['Product']['color'] ?></p>
                <p class="icon-tron"><img src="<?php echo $domain; ?>/images/icon-tron.png"/>Đối tượng sử dụng: <?php echo $product['Product']['lft'] ?></p>
                <p class="giaban">Giá bán: <span><?php echo number_format($product['Product']['price'],0,',','.') ?> đ</span></p>
                <?php if($product['Product']['first_image']): ?><p class="giaban" style="margin-top: -25px !important;">Giá khuyến mãi: <span><?php echo number_format($product['Product']['first_image'],0,',','.') ?> đ</span></p><?php endif; ?>
				<form class="num-product">
                    Số lượng: <input id="quantity" type="text" value="1"/>
                    <a href="javascript:void(1);" id="buy" class="btn-datmua-sp"></a>
                </form>
            </div>
        </div>
        
        <div id="usual1" class="usual"> 
            <ul class="menu-info"> 
              <li><a class="chitiet-sp" href="#tab1">Chi tiết sản phẩm</a></li> 
              <li><a class="danhgia-menu" href="#tab2">Đánh giá</a></li> 
              <li><a class="thanhtoan" href="#tab3">Thanh toán</a></li> 
            </ul> 
            <div id="tab1" class="content-info">
                <?php if (!empty($product['Product'])){ echo $product['Product']['detail'];} ?>
            </div> 
            <div id="tab2" class="content-info" >
                <div class="ykienkhachhang">Ý KIẾN KHÁCH HÀNG (<?php echo count($product_comment); ?> nhận xét)</div>
                                    <div class="binhluan">
                                        <?php foreach($product_comment as $comment) { ?>
                                        <div class="example">
                                            <p class="tenkhach">
                                                <?php echo $comment['ProductComment']['fullname'] ?> <span>(<?php echo $comment['ProductComment']['created_date'] ?>)</span>
                                            </p>
                                            <p class="danhgiasp"><?php echo $comment['ProductComment']['content'] ?></p>
                                        </div>
                                        <?php } ?>
                                    </div>
                                    <div class="form-binhluan">
                                        <form name="commentForm" action="<?php echo $domain ?>/product/comment" method="post">
                                            <span>GỬI BÌNH LUẬN</span><br/>
                                            <input name="fullname" class="info" type="text" placeholder="Họ & tên"><label>*</label><br/>
                                            <input name="email" class="info" type="text" placeholder="Email"><label>*</label><br/>
                                            <p>Đánh giá
                                            </p>
                                            <textarea  name="content" placeholder="Nội dung bình luận"></textarea><br/>
                                            <input type="submit" name="" value="GỬI" class="send">
                                            <input type="hidden" name="product_alias" value="<?php echo $product['Product']['alias'] ?>" >
                                            <input type="hidden" name="product_id" value="<?php echo $product['Product']['id'] ?>" >
                                        </form>
                                    </div>
            </div> 
            <div id="tab3" class="content-info">
                <div class="form-thanhtoan-on">
                                        <form name="myForm" action="<?php echo $domain;?>/check-out" method="post" >
                                            <p>
                                                <label class="label1">Họ tên người nhận</label><input name="username" type="text">
                                                <label class="label2">Địa chỉ</label><input name="address" type="text">
                                            </p>
                                            <p>
                                                <label class="label1">Số điện thoại</label><input name="phone" type="text" class="input1">
                                                <label class="label2">Email</label><input name="email" type="text">
                                            </p>
                                            <p class="btn-send-pr">
                                                <input type="hidden" name="soluong" id="total_qty" />
                                                <input type="hidden" name="id" value="<?php if(!empty($product['Product'])) echo $product['Product']['id']; ?>" />    
                                                <?php if(isset($product['Product']['first_image'])): ?>  
                                                <input type="hidden" name="price" value="<?php if(!empty($product['Product'])) echo $product['Product']['first_image']; ?>" />     
                                                <?php else: ?> 
                                                <input type="hidden" name="price" value="<?php if(!empty($product['Product'])) echo $product['Product']['price']; ?>" />     
                                                <?php endif; ?>  
                                                <input type="submit" onclick="return validateForm();" value="GỬI ĐƠN HÀNG">
                                            </p>
                                        </form>
                                    </div> 
                                    <div class="content-thanhtoan text-center">
                                        <hr>
                                        <p>KJT VietNam Co.,Ltd</p>
                                        <p>Tên TK: </p>
                                        <p>Số TK: </p>
                                        <p>Địa chỉ: 303, 3 Floor, B Building, 347 Doi Can Str, Lieu Giai Ward, Ba Dinh Dist,Hanoi</p>
                                        <p>Điện thoại: +84(4)6273-1346 | Hotline: </p>
                                        <p>Email: ysmilemart@gmail.com</p>
                                    </div>
            </div> 
        </div> 
        <div class="you-care">
            <p class="title-youcare">CÓ THỂ BẠN QUAN TÂM</p>
            <div class="care-product">
                <?php if(!empty($other_product)) {?>
                    <?php foreach ($other_product as $related){ ?>
                    <div class="pr-care text-center">
					<?php
                            echo $this->Html->link(
                                    $this->Html->image($related['Product']['images'], array('style' => 'max-width:121px;max-height:126px;border: 1px solid red;border-radius: 9px;', 'alt' => $related['Product']['name'])), array('controller' => 'Product', 'action' => 'detail', $related['Product']['alias']), array('escape' => false, 'title' => $related['Product']['name'])
                            );
                            ?>
                        
                        <p><?php echo $related['Product']['name'] ?></p>
                        <p>Giá: <span><?php echo number_format($related['Product']['price'],0,',','.');?> đ</span></p>
                    </div>
                    <?php } ?>
                <?php } ?>
            </div>
        </div>
    </div>
</div><!--content-->
<script type="text/javascript"> 
  $("#usual1 ul").idTabs();
  $(document).ready(function(){
        $("#total_qty").attr("value", $('#quantity').val());
       $("#buy").click(function(){
            console.log($('#quantity').val());
            if(!$('#quantity').val()){
                alert("Bạn chưa nhập số lượng");
                window.location = window.location;
            }else if($('#quantity').val() <= 0){
                alert("Số lượng mua ít nhất là 1");
                window.location = window.location;
            }else if(Number($('#quantity').val())){
                $(".thanhtoan").trigger("click");
            }
        });     
    });  
</script>
<script>
    function validateForm(){
        var username = document.forms["myForm"]["username"].value;
        var phone = document.forms["myForm"]["phone"].value;
        var phone_regex = /^[0-9\-\+]{9,15}$/;
        var address = document.forms["myForm"]["address"].value;
        var soluong = document.forms["myForm"]["soluong"].value;
        var id = document.forms["myForm"]["id"].value;
        if (username == null || username == "") {
            alert("Bạn chưa nhập tên");
            return false;
        }else if(address == null || address == "") {
            alert("Bạn chưa nhập địa chỉ");
            return false;
        }else if(soluong == null || soluong <= 0) {
            alert("Số lượng mua ít nhất là 1");
            return false;
        }else if(!phone_regex.test(phone)){
            alert("Số điện thoại không hợp lệ!");
            return false;
        }else if(id == null || id <= 0) {
            alert("Có lỗi xảy ra!");
            return false;
        }else{
            return true;
        }
        
    }
</script>